package LEETCODE2023;

import java.util.ArrayList;
import java.util.Comparator;

public class Solution_2373 {

    public int[][] largestLocal(int[][] grid) {
        int len = grid.length;
        if(len<3){
            return null;
        }
        int[][] ans=new int[len][len];
        for (int i = 1; i < len-1; i++) {
            for (int j = 1; j < len-1; j++) {
                ans[i-1][j-1]=search(grid,i,j);
            }
        }
        return ans;
    }

    public int search(int[][] nums,int x,int y){
        int max = nums[x][y];
        for (int i = x-1; i <= x+1; i++) {
            for (int j = y-1; j <=y+1; j++) {
                max=Math.max(max,nums[i][j]);
            }
        }
        return max;
    }
}
